""" New Project dialog """

import wx
import c.ui.wxw.common as common

colourList = [ "Empty Project", "Basic Project", "Drawing Project" ]

class NewProjectDialog(wx.Dialog):

	def __init__(self, parent):
		wx.Dialog.__init__(self, parent, -1, "New Project", style=wx.DEFAULT_DIALOG_STYLE)
		self.mw = parent

		self.SetMinSize((280,10))

		self.projtype = wx.Choice(self, -1, choices=colourList)
		self.projtype.SetSelection(len(colourList)-1)

		hbox3 = wx.BoxSizer(wx.HORIZONTAL)
		
		self.textctrl = wx.TextCtrl(self, -1, "", style = wx.TE_PROCESS_ENTER)
		self.textctrl.Bind(wx.EVT_TEXT, self.onUpdate)
		self.textctrl.Bind(wx.EVT_TEXT_ENTER, self.onEnter)
		self.textctrl.SetFocus()
		hbox3.Add(wx.StaticText(self, -1, "Project Name"), 0, wx.ALIGN_CENTRE_VERTICAL, 0)
		hbox3.Add(self.textctrl, 1, wx.EXPAND | wx.LEFT , 10)

		self.ok = wx.Button(self, wx.ID_OK, "OK")
		self.ok.SetDefault()
		self.ok.Disable()
		cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
		
		dlgsizer = wx.BoxSizer(wx.VERTICAL)
		dlgsizer.Add(self.projtype, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10)
		dlgsizer.Add(hbox3, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10)
		dlgsizer.Add(wx.StaticLine(self, -1), 0, wx.TOP | wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
		
		btnsizer = wx.StdDialogButtonSizer()
		btnsizer.AddButton(self.ok)
		btnsizer.AddButton(cancel)
		btnsizer.Realize()
		
		dlgsizer.Add(btnsizer, 0, wx.ALL | wx.ALIGN_RIGHT, 10)
		
		self.SetSizer(dlgsizer)

		self.Fit()
		self.Centre()

	def GetValue(self):
		pt = self.projtype.GetString(self.projtype.GetSelection())
		return (pt, self.textctrl.GetValue())

	def onUpdate(self, evt):
		self.ok.Enable(self.textctrl.GetValue()!="")

	def onEnter(self, evt):
		self.EndModal(wx.ID_OK)

